package com.org.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.Scheduled;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author Rainy-Heights
 * @version 1.0
 * @Date 2023/3/5 14:10
 */
@Configuration
public class ScheduledConfig {

    //配置定时任务类，创建定时任务，插入到boot里面执行

    @Scheduled(cron = "0 0/2  * * * ?")
    public void scheduled01(){
        SimpleDateFormat dateFormat=new SimpleDateFormat("yyyy年MM月dd日 HH时mm分ss秒");
        System.out.println("定时计划, 现在的时间是:"+dateFormat.format(new Date()));
    }
}
